//
//  TbCategoryTitleModel.m
//  quxiangtao
//
//  Created by xbmios on 2018/9/26.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "TbCategoryTitleModel.h"

@implementation TbCategoryTitleModel
//+ (NSDictionary *)mj_replacedKeyFromPropertyName {
//    return @{@"classid":@"id",@"classname":@"name"};
//}
+ (void)getCategoryTitleWithUrl:(NSString *)url successBlock: (HttpRequestSuccess)successBlock failBlock:(HttpRequestFailed)failBlock {
    
    [PPNetworkHelper POST:url parameters:nil success:^(id responseObject) {
        
        NSLog(@"淘宝分类数据获取%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] == 1) {
            
            NSArray *array = responseObject[@"data"];
            
            NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:responseObject];
            
            if (array.count > 0) {
                
                NSArray *arr = [TbCategoryTitleModel mj_objectArrayWithKeyValuesArray:array];
                [dict removeObjectForKey:@"data"];
                [dict setObject:arr forKey:@"data"];
                
            }
            
            if (successBlock) {
                
                successBlock(dict);
            }
            
            
        }else {
            
            [[KYAlertView sharedInstance] showAlertViewWithMessage:responseObject[@"msg"]];
        }
        
    } failure:^(NSError *error) {
        
        if (failBlock) {
            
            NSLog(@"error:%@", error);
            
            
            failBlock(error);
        }
        
    }];
}

@end
